@extends('layouts._app')
@section('content')
    <body>
    <div class="wrap-container" style="overflow-x: auto;">
        <div class="column-content-detail">
            {!! Form::open(['route' => 'blog.invitation.index','class'=>'layui-form','method'=>'get']) !!}
            <div class="layui-form-item">
                <div class="layui-inline tool-btn">
                    <a class="layui-btn layui-btn-small layui-btn-primary" id='email-refresh-btn'
                       href="{{route('blog.invitation.index')}}"
                       data-title='刷新'>
                        <i class="layui-icon">&#x1002;</i>
                    </a>
                </div>
                <div class="layui-inline">
                    {!! Form::search('name',"{$request['name']}",['class'=>'layui-input','placeholder'=>'用户名/手机号/邮箱']) !!}
                </div>
                {!! Form::submit('搜索',['class'=>'layui-btn layui-btn-normal','lay-submit'=>'search']) !!}
            </div>
            {!! Form::close() !!}
            <ul id="invitation"></ul>
        </div>
    </div>
    <div class="timg" style="display:none"><img src="{{asset('static/admin/images/timg.jpg')}}" alt="暂无数据"></div>
    <script src="{{asset('static/admin/layui/layui.js')}}" type="text/javascript" charset="utf-8"></script>
    <script src="{{asset('js/jquery.min.js')}}" type="text/javascript" charset="utf-8"></script>
    <script>
        $(function () {
            layui.use(['jquery', 'tree', 'form'], function () {
                var $ = layui.jquery,
                    tree = layui.tree;

                $.ajax({
                    type: 'POST',
                    url: '{{route('blog.invitation.tree')}}',
                    data: {name: '{{$request['name']}}'},
                    dataType: "json",
                    beforeSend: function () {
                        layer.load(1, {
                            shade: [0.1, '#333333'] //0.1透明度的白色背景
                        });
                    },
                    complete: function (XHR) {
                        XHR = null;
                    },
                    error: function (xhr) {//获取ajax的错误信息
                        layer.alert(xhr.responseText, "Failed", function () {
                            layer.closeAll();
                        });
                    },
                    success: function (res) {
                        layer.closeAll();
                        if (res.code == 403) {
                            layer.msg(res.msg, {icon: 4, time: 3000})
                            return false;
                        }
                        if (res.code != 200) {
                            layer.msg(res.msg, {icon: 5, time: 3000})
                            return false;
                        }
                        if (res.data.length <= 0) $(".timg").attr('style', 'display:block');
                        tree({
                            elem: '#invitation', skin: 'shihuang', nodes: res.data,
                            branch: ["&#xe613;", "&#xe612;"], leaf: "&#xe612;"
                        });
                    }
                })
            })
        })
    </script>
    </body>
@endsection
